import request from '@/utils/request'

// 获取字段映射关系
export function getOption(params) {
  return request({
    url: `/v1/base/option`,
    method: 'get',
    params
  })
}

// 获取操作日志
export function log(params) {
  return request({
    url: `/v1/base/log`,
    method: 'get',
    params
  })
}

// 获取供应商列表
export function supplier(data) {
  return request({
    url: `/v1/base/supplier`,
    method: 'post',
    data
  }).then(res => res.data.map(d => ({ label: d.supplier_name, value: d.s_id })))
}

// 平台
export function platforms() {
  return request({
    baseURL: window.APP_GETEWAY.base,
    url: `/v1/platform/platforms`,
    method: 'get',
  }).then(res => res.data.map(d => ({ label: d.platform_name, value: d.platform_id })))
}
// 仓库
export function warehouse(params) {
  return request({
    baseURL: window.APP_GETEWAY.wms,
    url: `/api/warehouse-option`,
    method: 'get',
    params
  })
}
// 国家
export function countrys(params) {
  return request({
    baseURL: window.APP_GETEWAY.goods,
    url: `/api/goods/get-countrys`,
    method: 'get',
    params
  })
}
// 上传文件
export function upload(data) {
  return request({
    url: `/v1/base/upload`,
    method: 'post',
    data,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  })
}
// 上传文件
export function uploadFeishu(data) {
  return request({
    url: `/v1/base/upload/feishu`,
    method: 'post',
    data,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  })
}

// 获取邮箱
export function getUserEmail(params) {
  return request({
    baseURL: window.APP_GETEWAY.auth,
    url: '/tenant/get-user-email',
    method: 'get',
    params
  })
}

// 员工
export function personnel(params) {
  return request({
    baseURL: window.APP_GETEWAY.auth,
    url: '/tenant/organization',
    method: 'get',
    params
  }).then(res => res.data)
}

// 部门
export function department(params) {
  return request({
    baseURL: window.APP_GETEWAY.auth,
    url: '/department',
    method: 'get',
    params
  }).then(res => res.data)
}

// 平台站点
export function sites() {
  return request({
    baseURL: window.APP_GETEWAY.base,
    url: '/v1/platform/tree',
    method: 'get'
  }).then(res => res.data)
}

// 根据用户ID获取部门信息
export function getDepartment(params) {
  return request({
    url: `/v1/base/get-department`,
    method: 'get',
    params
  })
}
// 仓库属性枚举
export function warehouseList() {
  return request({
    baseURL: window.APP_GETEWAY.wms,
    url: `api/warehouse-enum`,
    method: 'get',
  }).then(res => res.data.wms_platform)
}

// 获取分类列表
export function classify(params) {
  return request({
    baseURL: window.APP_GETEWAY.goods,
    url: '/base/backend-classification/get-list',
    method: 'get',
    params
  }).then(res => res.data)
}

// 获取角色
export function role(params) {
  return request({
    baseURL: window.APP_GETEWAY.auth,
    url: '/options',
    method: 'get',
    params: {get: 'optRole'}
  }).then(res => res.data.optRole)
}

 // 获取省市区联动
 export function area(params) {
  return request({
    url: '/v1/base/area',
    method: 'get',
    params
  })
}